<#include "../../common/header.htm">
<div class="content-wrapper">
	<section class="content" id="holiday">
		<div class="base_dict_search">
			<span>假日名称</span>
			<input  type="text" v-model="holidayName">
			<button @click="onSubmit">查询</button>
			<button onclick="openHolidayDialog('新增节假日',null)">新增</button>
		</div>
		<div class="dg">
			<table id="dg"></table>
		</div>
	</section>
</div>
<script>
	var vm=new Vue({
		el:"#holiday",
		data:{
			holidayName:""
		},
		methods:{
			onSubmit(){
				dg()
			},
			reset(){
				this.holidayName=""
			},
		}
	})
	dg()
	function openHolidayDialog(title,id) {
		var param={
			id:id
		}
		var d = top.dialog({
			id:"test",
			title : title,
			modal : true,
			url : '${ctx}/holiday/openHolidayDialog',
			height : 620,
			data : param,
			width : 800
		});
		d.addEventListener('close', function () {
			dg();
		});
		d.show();
	}
	function dg(){
			$('#dg').datagrid({
				url: '${ctx}/holiday/page',
				method: 'post',
				iconCls: 'icon-save',
				queryParams:{//每次请求的参数
					holidayName:vm.holidayName
				},
				pageSize:30,
				pageList:[30,50,100,150,200],
				pageNumber:1,//当前页号,
				//sortName:"TOTALMONEY",//排序列名称 设置后将向后台传送名为sort的post/get参数
				//sortOrder:"desc",//排序列升降序 设置后将向后台传送名为order的post/get参数
				loadMsg:"正在加载，请稍后",//加载数据时的提示信息
				emptyMsg:"暂无信息",//加载数据为空时的信息
				height: ($(window).height())-($('.base_dict_search').outerHeight(true))-50,
				rownumbers:true,//序号
				fitColumns: true,//使表格自适应页面宽度
				pagination: true,//是否分页
				singleSelect: true,
				columns:[[ //每一列的具体设置。
					{field:'holidayName',title:'假日名称'},
					{field:'holidayDate',title:'日期',
						formatter: function(value,row,index){
							return getMyDate(value)
						}
					},
					{field:'errorDays',title:'误差天数'},
					{field:'status',title:'启用状态',
						formatter: function(value,row,index){
							return value?"启用":"不启用"
						}
					},
					{field:'dateType',title:'日期类型'},
					{field:'remark',title:'备注'},
					{field:'operate',title:'操作',
						formatter: function(value,row,index){
							let id=row.id;
							let s="<a href='#' onclick='edit("+id+")'>修改</a>&nbsp;&nbsp;<a href='#' onclick='del("+id+")'>删除</a>"
							return s
						}
					},
				]],
				onHeaderContextMenu: function(e, field){
					e.preventDefault();
					if (!cmenu){
						createColumnMenu();
					}
					cmenu.menu('show', {
						left:e.pageX,
						top:e.pageY
					});
				},
				onLoadSuccess: function(){
					// refreshSize();
				}
			});
	}
	function edit(id) {
		openHolidayDialog("编辑节假日",id)
	}
	function del(id) {
		var d = dialog({
			title: '提示',
			content: '您确定要删除么！',
			okValue: '确 定',
			ok: function() {
				$.ajax({
					url:"${ctx}/holiday/del",
					type: "post",
					data: {
						id:id,
					},
					dataType: "json",
					success: function (msg) {
						if (msg.flag) {
							vm.$message('删除成功');
							dg()
						}
					},

				})
				return true;
			},
			cancelValue: '取消',
			cancel: function() {
			}
		}).show()
	}
</script>
<style>
	.base_dict_search{
		padding: 20px;
	}
	.dg{
		margin-left: 20px;
	}
</style>